package com.service.impl;

import com.alibaba.fastjson.JSON;
import com.common.utils.DateUtil;
import com.common.utils.HttpUtil;
import com.service.Ig507ComService;
import com.vo.Ig507yjbg;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Service("ig507ComService")
public class Ig507ComServiceImpl implements Ig507ComService {

    /**
     * yjbg
     * @return
     */
    @Override
    public List<Ig507yjbg> yjbg() {

        String time=DateUtil.getMM_DD();
        String url="http://ig507.com/data/all/finyjbb/2021_3?licence=62CD0BE7-8A21-6224-1C2E-A7A3CA6E5E39";

        String result = HttpUtil.sendGet(url, null);
        List<Ig507yjbg> ig507yjbgs = JSON.parseArray(result, Ig507yjbg.class);

        if(CollectionUtils.isEmpty(ig507yjbgs)){
            return  null;
        }

        List<Ig507yjbg> lsit=new ArrayList<>();
        for (Ig507yjbg ig507yjbg : ig507yjbgs) {
            String mgsytb = ig507yjbg.getMgsytb();
            String rdate = ig507yjbg.getRdate();

            if(!rdate.equals(time)){
                continue;
            }
            if(new BigDecimal(mgsytb).compareTo(new BigDecimal("500"))==1){
                lsit.add(ig507yjbg);
            }
        }

        return lsit;
    }
}
